/*

* ------------------------------------------------------------------------
* ------------------------------------------------------------------------
* |     Smart-Shop开源商城系统/ Java商城-首选电商平台系统 请务必保留此注释头信息
* |     开源地址: https://gitee.com/ningbo-qishan/gruul-mall
* ------------------------------------------------------------------------
* ------------------------------------------------------------------------
* |     可正常分享和学习源码,未经授权 不可商用！
* |     商业版中台购买/开源版商业授权 联系技术客服
* |     官网:  https://www.73app.cn/
* ------------------------------------------------------------------------
* ------------------------------------------------------------------------
* |     Copyright (c) 2016-2999 宁波启山智软科技有限公司
* |     版权所有 ,侵权必究！
* ------------------------------------------------------------------------

*/
package com.medusa.gruul.account.web.controller;


import com.medusa.gruul.account.api.entity.MemberSwitch;
import com.medusa.gruul.account.model.dto.MemberCardInfoRankStatusDto;
import com.medusa.gruul.account.model.dto.MemberCardInfoStatusDto;
import com.medusa.gruul.account.model.vo.MemberCardInfoListVo;
import com.medusa.gruul.account.service.IMemberCardInfoService;
import com.medusa.gruul.common.core.annotation.EscapeLogin;
import com.medusa.gruul.common.core.util.Result;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Description
 * @Author zhaokw
 * @Date 22:39 2020\5\13 0013
 **/
@RestController
@RequestMapping("/manager")
public class MemberCardInfoController {

    @Autowired
    private IMemberCardInfoService memberCardInfoService;


    /**
     * 显示打开关闭会员功能
     *
     * @param
     * @return
     */
    @GetMapping("/getMemberCardInfoSwitch")
    @ApiOperation(value = "显示打开关闭会员功能")
    public Result getMemberCardInfoSwitch() {
        List<MemberSwitch> memberCardInfoSwitchList = memberCardInfoService.getMemberCardInfoSwitch();
        return Result.ok(memberCardInfoSwitchList);
    }

    /**
     * 后台关闭打开会员卡功能
     *
     * @param
     * @return
     */
    @PostMapping("/setMemberCardInfoStatus")
    @ApiOperation(value = "后台关闭打开会员卡功能")
    public Result setMemberCardInfoStatus(@RequestBody @Validated MemberCardInfoStatusDto memberCardInfoStatusDto) {
        memberCardInfoService.setMemberCardInfoStatus(memberCardInfoStatusDto);
        return Result.ok();
    }

    /**
     * 后台停用开启会员卡各个等级
     *
     * @param
     * @return
     */
    @PostMapping("/updateMemberCardInfoStatus")
    @ApiOperation(value = "后台停用开启会员卡各个等级")
    public Result updateMemberCardInfoStatus(@RequestBody @Validated List<MemberCardInfoRankStatusDto> memberCardInfoRankStatusDtoList) {
        memberCardInfoService.updateMemberCardInfoStatus(memberCardInfoRankStatusDtoList);
        return Result.ok();
    }

    @GetMapping("/getMemberCardInfo")
    @ApiOperation(value = "pc端获取会员卡信息")
    public Result<MemberCardInfoListVo> getMemberCardInfo() {
        MemberCardInfoListVo memberCardInfo = memberCardInfoService.getMemberCardInfo();
        return Result.ok(memberCardInfo);
    }

    /**
     * 后台保存会员卡信息
     *
     * @param
     * @return
     */
    @PostMapping("/saveMemberCardInfo")
    @ApiOperation(value = "后台保存会员卡信息")
    public Result saveMemberCardInfo(@RequestBody @Validated MemberCardInfoListVo memberCardInfo) {
        memberCardInfoService.saveMemberCardInfo(memberCardInfo);
        return Result.ok();
    }

}
